<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %> 
<%@ taglib prefix="s" uri="/struts-tags"%>
<%
String path = request.getContextPath();
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <title>编辑用户</title>
  </head>
  <body>
  <script type="text/javascript">
   (function($){  
     $.imap = function(){  
          var imap = this.map = {};  
          this.get = function(key){  
              var val = eval("imap."+key);  
              return  (typeof val === undefined) ? null : val;  
          };  
          this.set = function(key,value){  
              eval("imap."+key+"=value");  
          };  
     };  
  })(jQuery); 
  var map = new jQuery.imap();
  function setContent(value){
  	var content = map.get('I'+value);
  	if(content == null || content == ""){
  		$.ajax({
		        type: 'GET',
		        url: '<%=path %>/ajax/getTemplate.do?id='+value,
		        dataType: 'json',
		    	success: function (data){
		    		if(data != null){
		    			$('#msg_content').text(data.content);
		    		}
		        }
		 	});
  	}else{
  		$('#msg_content').text(content);
  	}
  	
  }
  
  
  function changeType(value){
  	if(value == 'attime'){
  		$("#sendTimeDIV").show();
  	}else{
  		$("#sendTimeDIV").hide();
  	}
  }
  </script>
  
  
<div class="pageContent">
	<form method="post" action="<%=path %>/sendMsg/saveSendMsg.action" class="pageForm required-validate" onsubmit="return validateCallback(this, navTabAjaxDone);">
		<div class="pageFormContent" layoutH="76">
			<p>
				<label>短信类型：</label>
				<select id="sendTimeType" onChange="changeType(this.value);">
                     <option value="">选择类型</option>
                     <option value="ontime">即时短信</option>
                     <option value="attime">定时短信</option>
                </select>
			</p>
			<p>
					<label>模板：</label>
					<select name="sendMsgVO.template.id" onChange="setContent(this.value);">
                        <option value="">选择模板</option>
                        <c:forEach var="item" items="${templates}">
                        	<option value="${item.id}" ${sendMsgVO.template.id eq item.id ? "selected" : "" }>${item.name}</option>
                        	<script>map.set('I${item.id}','${item.content}');</script>
                        </c:forEach>
                   </select>
				</p>
			
			<p id="sendTimeDIV" style="display:none">
					<label>发送时间：</label>
					<input name="sendMsgVO.sendTime" id="sendTime" value="<s:date name='sendMsgVO.sendTime' format="yyyy-MM-dd HH:mm:ss"/>" class="date" type="text"
								dateFmt="yyyy-MM-dd HH:mm:ss" size="30"/>
					<input name="sendMsgVO.users" value="${memberIds}" type="hidden"/>
			</p>
			<p>
					<label>内容：</label>
					<textarea readonly style="margin-left:130px;" id="msg_content" name="sendMsgVO.content" cols="50" rows="5"><s:property value="sendMsgVO.content" /></textarea>
			</p>
		</div>
		<div class="formBar">
			<ul>
				<!--<li><a class="buttonActive" href="javascript:;"><span>保存</span></a></li>-->
				<li><div class="buttonActive"><div class="buttonContent"><button type="submit">保存</button></div></div></li>
				<li>
					<div class="button"><div class="buttonContent"><button type="button" class="close">取消</button></div></div>
				</li>
			</ul>
		</div>
	</form>
</div>

</body>
</html>
